home *** CD-ROM | disk | FTP | other *** search
- Path: news.sni.de!news
- From: Josef Moellers <mollers.pad@sni.de>
- Newsgroups: comp.lang.c
- Subject: Re: Array Parameters
- Date: 4 Jan 1996 07:52:36 GMT
- Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
- Message-ID: <4cg104$qmp@nervous.pdb.sni.de>
- References: <wayne.820650643@hawk> <4ce349$4j9@hacgate2.hac.com> <820701694snz@genesis.demon.co.uk>
- NNTP-Posting-Host: uranium.pdb.sni.de
- X-Newsreader: NN version 6.5.0 #2
-
- In <820701694snz@genesis.demon.co.uk> Lawrence Kirby <fred@genesis.demon.co.uk> writes:
-
- [ ... ]
-
- > It is impossible
- >to specify an array as a function parameter since, as in the example above,
-
- Well, if you MUST pass an array by value and not by reference, wrap it
- into a structure:
-
- struct foo {
- int array[100];
- };
- ...
- func(struct foo bar)
- {
- ...
- bar.array[23] = 25;
- ...
- }
- ...
- struct foo foo_array;
- ...
- foo_array.array[23] = 7;
- func(foo_array);
- printf("%d\n", foo_array.array[23]);
- ...
-
- will print "7", rather than "23".
-
- Please note that this is very expensive at runtime.
- --
- Josef Moellers mollers.pad@sni.de
-